using UnityEngine;
using System.Collections;
using System.Threading;

public class Fade : MonoBehaviour
{
    public GameObject[] fades;
    public int timeFading;
    public bool canDestroy { get; private set; }

    void Start()
    {
        StartCoroutine(changeAlpha());
    }

    IEnumerator changeAlpha()
    {
        iTween.FadeTo(fades[0], 0, timeFading);
        yield return new WaitForSeconds(timeFading);

        iTween.FadeTo(fades[1], 0, timeFading);
        yield return new WaitForSeconds(timeFading);

        iTween.FadeTo(fades[2], 0, timeFading);
        yield return new WaitForSeconds(timeFading);

        iTween.FadeTo(fades[3], 0, timeFading);
        yield return new WaitForSeconds(timeFading);

        canDestroy = true;
    }
}
